package cn.iocoder.yudao.module.biz.dal.mysql.expand.targets.partner;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.biz.dal.dataobject.expand.targets.partner.ExpandTargetPartnerDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.biz.controller.admin.expand.targets.partner.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 拓展目标_合作伙伴 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ExpandTargetPartnerMapper extends BaseMapperX<ExpandTargetPartnerDO> {

    default PageResult<ExpandTargetPartnerDO> selectPage(ExpandTargetPartnerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExpandTargetPartnerDO>()
                .likeIfPresent(ExpandTargetPartnerDO::getName, reqVO.getName())
                .likeIfPresent(ExpandTargetPartnerDO::getShortName, reqVO.getShortName())
                .eqIfPresent(ExpandTargetPartnerDO::getCooperateMode, reqVO.getCooperateMode())
                .eqIfPresent(ExpandTargetPartnerDO::getCooperateArea, reqVO.getCooperateArea())
                .eqIfPresent(ExpandTargetPartnerDO::getLocation, reqVO.getLocation())
                .eqIfPresent(ExpandTargetPartnerDO::getAddress, reqVO.getAddress())
                .eqIfPresent(ExpandTargetPartnerDO::getTradeType, reqVO.getTradeType())
                .eqIfPresent(ExpandTargetPartnerDO::getCostMode, reqVO.getCostMode())
                .likeIfPresent(ExpandTargetPartnerDO::getContactName, reqVO.getContactName())
                .eqIfPresent(ExpandTargetPartnerDO::getContactNumber, reqVO.getContactNumber())
                .eqIfPresent(ExpandTargetPartnerDO::getMainProduct, reqVO.getMainProduct())
                .eqIfPresent(ExpandTargetPartnerDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ExpandTargetPartnerDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ExpandTargetPartnerDO::getOwnerUserId, reqVO.getOwnerUserId())
                .orderByDesc(ExpandTargetPartnerDO::getId));
    }

    /**
     * 检查拓展目标_客户是否存在
     * @param name
     * @return 存在返回1，不存在返回0
     */
    Integer checkExistByName(@Param("name") String name);

}